home *** CD-ROM | disk | FTP | other *** search
-
- Listing 8
-
- //
- // operator+=
- //
- rational &rational::operator+=(rational r)
- {
- num = num * r.denom + r.num * denom;
- denom *= r.denom;
- return *this;
- }
-
- //
- // operator+ written in terms of operator+=
- //
- rational rational::operator+(rational r)
- {
- rational result(*this);
- return result += r;
- }
-